export interface SwaggerItem {
  description?: string;
  items?: SwaggerItem;
  properties?: Record<string, SwaggerItem>;
  additionalProperties?: SwaggerItem;
  format?: string;
  enum?: string[];
  maximum?: number;
  minimum?: number;
  // allOf?: [
  //   { $ref: string },
  //   { properties: Record<string, SwaggerItem>; type: string }
  // ];
  type?: string | string[]
  $ref?: string;
}

export interface SwaggerParameter {
  name: string;
  in: string;
  description?: string;
  required?: boolean;
  style?: string;
  schema?: SwaggerItem;
}

export interface SwaggerSchema {
  title: string;
  type: string | string[];
  nullable?: boolean;
  required?: string[];
  properties?: Record<string, SwaggerItem>;
  description?: string;
}

export interface MethodRequest {
  summary: string;
  tags: string[];
  operationId: string;
  description: string;
  deprecated: boolean;
  security?: unknown[];
  parameters?: SwaggerParameter[];
  requestBody?: {
    content?: {
      'application/json': {
        schema: SwaggerItem;
      };
    };
  };
  responses: {
    '200'?: {
      content?: {
        'application/json'?: {
          schema?: SwaggerItem;
        };
        '*/*'?: {
          schema?: SwaggerItem;
        };
      };
      description: string;
      headers: Record<string, unknown>;
    };
  };
}

export type Methods = ['get', 'post', 'put', 'delete', 'patch'];
export type SwaggerPath = {
  [key in Methods[number]]?: MethodRequest;
};

export interface SwaggerApi {
  apiInfo?: string;
  url: string;
  method: string;
  path?: SwaggerParameter[];
  query?: SwaggerParameter[];
  header?: SwaggerParameter[];
  data?: SwaggerItem;
  formData?: SwaggerSchema;
  response?: string;
}

export interface SwaggerData {
  paths: Record<string, SwaggerPath>;
  components: {
    schemas: Record<string, SwaggerSchema>;
  };
}
